//
//  ScrollEditView.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/10/8.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class ScrollEditView: UIView {
    var scrollView:UIScrollView!//底部scrollView
    var inputTitleTV:UITextView!//输入标题的textF
    var line1:UIView!//分割线1
    var inputMenuTV:UITextView!//输入标签
    var line2:UIView!//分割线2
    var inputBodyTV:UITextView!//输入正文
    var placeholderTV1:UILabel!//textview的模拟placeholder
    var placeholderTV2:UILabel!//textview的模拟placeholder
    var placeholderTV3:UILabel!//textview的模拟placeholder
    
    
    override init(frame: CGRect) {
        scrollView = UIScrollView()
        inputTitleTV = UITextView()
        line1 = UIView()
        inputMenuTV = UITextView()
        line2 = UIView()
        inputBodyTV = UITextView()
        placeholderTV1 = UILabel()
        placeholderTV2 = UILabel()
        placeholderTV3 = UILabel()
        super.init(frame: frame)
        self.createScrollView()
        self.createInputTitle()
        self.createLine1()
        self.createMenu()
        self.createLine2()
        self.createBodyText()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //添加scrollview
    func createScrollView(){
        scrollView.frame = MainBounds
        scrollView.contentSize = CGSizeMake(WidthAPP, HeightAPP+1)
        self.addSubview(scrollView)
    }
    
    //添加输入标题
    func createInputTitle(){
        inputTitleTV.frame = CGRectMake(10*SCALEW, 64, WidthAPP-20*SCALEW, 51)
        inputTitleTV.textAlignment = .Left
        inputTitleTV.font = BaseFunc.getSystemFont(20)
        inputTitleTV.textColor = UIColor.blackColor()
        inputTitleTV.becomeFirstResponder()
        inputTitleTV.scrollEnabled = false
        self.scrollView.addSubview(inputTitleTV)
        
        placeholderTV1.frame = CGRectMake(5*SCALEW, 10, 200*SCALEW, 21)
        placeholderTV1.font = BaseFunc.getLightFont(21)
        placeholderTV1.textAlignment = .Left
        placeholderTV1.textColor = BaseFunc.createCustomColor(200, b: 200, g: 200, a: 1)
        placeholderTV1.text = "请输入标题"
        self.inputTitleTV.addSubview(placeholderTV1)
    }
    
    //添加分割线1
    func createLine1(){
        line1.frame = CGRectMake(17*SCALEW, 119, WidthAPP-34*SCALEW, 1)
        line1.backgroundColor = Theme.BGColor
        self.scrollView.addSubview(line1)
    }
    
    //添加标签
    func createMenu(){
        inputMenuTV.frame = CGRectMake(10*SCALEW, 120, WidthAPP-20*SCALEW, 48)
        inputMenuTV.textAlignment = .Left
        inputMenuTV.font = BaseFunc.getLightFont(18)
        inputMenuTV.textColor = BaseFunc.createCustomColor(172, b: 58, g: 70, a: 1)
        inputMenuTV.scrollEnabled = false
        
        self.scrollView.addSubview(inputMenuTV)
        
        placeholderTV2.frame = CGRectMake(5*SCALEW, 12, 100*SCALEW, 18)
        placeholderTV2.font = BaseFunc.getLightFont(18)
        placeholderTV2.textAlignment = .Left
        placeholderTV2.textColor = BaseFunc.createCustomColor(200, b: 200, g: 200, a: 1)
        placeholderTV2.text = "请选择标签"
        self.inputMenuTV.addSubview(placeholderTV2)
    }
    
    //添加分割线2
    func createLine2(){
        line2.frame = CGRectMake(17*SCALEW, 169, WidthAPP-34*SCALEW, 1)
        line2.backgroundColor = Theme.BGColor
        self.scrollView.addSubview(line2)
    }
    
    //输入正文
    func createBodyText(){
        inputBodyTV.frame = CGRectMake(10*SCALEW, 170, WidthAPP-20*SCALEW, (HeightAPP-64))
        inputBodyTV.textAlignment = .Left
        inputBodyTV.font = BaseFunc.getLightFont(15)
        inputBodyTV.textColor = UIColor.blackColor()
        inputBodyTV.scrollEnabled = false
        self.scrollView.addSubview(inputBodyTV)
        
        placeholderTV3.frame = CGRectMake(5*SCALEW, 10, 100*SCALEW, 18)
        placeholderTV3.font = BaseFunc.getLightFont(18)
        placeholderTV3.textAlignment = .Left
        placeholderTV3.textColor = BaseFunc.createCustomColor(200, b: 200, g: 200, a: 1)
        placeholderTV3.text = "请输入正文"
        self.inputBodyTV.addSubview(placeholderTV3)
        
    }
    
    
    
    

}







